//
//  SEGSelectCommunityHeaderView.m
//  SEGUhomeStandard
//
//  Created by 揭婧雯 on 2018/8/27.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGSelectCommunityHeaderView.h"
@interface SEGSelectCommunityHeaderView ()
/**
 标签
 */
@property (nonatomic, strong)UILabel *label;

@end

@implementation SEGSelectCommunityHeaderView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUpUI];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    self.backgroundColor = kColor_W;
    
    self.iconImg = [[UIImageView alloc] init];
    [self addSubview:self.iconImg];
    [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self).offset(0);
        make.left.equalTo(self).offset(15);
    }];
    
    UILabel *label = [[UILabel alloc] init];
    label.font = kFont_13;
    label.textColor = kColor_3;
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self).offset(0);
        make.left.equalTo(self.iconImg.mas_right).offset(5);
    }];
    self.label = label;
}

- (void)setType:(SEGCommunityHeaderType)type {
    CGFloat padding = 0;
    switch (type) {
        case SEGCommunityHeaderType_Center:
            padding = 0;
            break;
        case SEGCommunityHeaderType_Bottom:
            padding = 9;
            break;
    }
    [self.iconImg mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self).offset(padding);
    }];
    [self.label mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self).offset(padding);
    }];
}

- (void)setText:(NSString *)text {
    _text = text;
    self.label.text = text;
}

@end
